home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / DONALDXC / FILEOPEN.C < prev    next >
Text File  |  1990-05-01  |  1KB  |  56 lines

  1. /********************************/
  2. /* File: FIleOpen.c                */
  3. /*                                */
  4. /* open the file whose name and */
  5. /* working directory id are     */
  6. /* passed as parameters.  This    */
  7. /* information can be obtained    */
  8. /* using GetFileNameToLoad...    */
  9. /*                                */
  10. /* Paramters:                    */
  11. /* param0 = file name    num        */
  12. /* param1 = directory id         */
  13. /*                                */
  14. /* Out:                            */
  15. /* File RefNum if opened, 0     */
  16. /* otherwise                    */
  17. /* ----------------------------    */
  18. /********************************/
  19.  
  20. #include    <MacTypes.h>
  21. #include    <OSUtil.h>
  22. #include    <MemoryMgr.h>
  23. #include    <FileMgr.h>
  24. #include    <ResourceMgr.h>
  25. #include    <pascal.h>
  26. #include    <string.h>
  27. #include     "HyperXCmd.h"
  28. #include    "HyperUtils.h"
  29.  
  30.     
  31. pascal void main( paramPtr )
  32.     XCmdBlockPtr    paramPtr;
  33. {
  34.     char         *filename;
  35.     Str31        str, fName;
  36.     short        wdid, refnum;
  37.  
  38.     HLock( paramPtr->params[0] );
  39.     ZeroToPas( paramPtr, *(paramPtr->params[0]), &fName );
  40.     HUnlock( paramPtr->params[0] );
  41.     
  42.     /* convert the wdid to a usable form */
  43.     HLock( paramPtr->params[1] );
  44.     ZeroToPas( paramPtr, *(paramPtr->params[1]), &str );
  45.     HUnlock( paramPtr->params[1] );
  46.     wdid = (short)StrToNum( paramPtr, &str );
  47.     
  48.     if( FSOpen( &fName, wdid, &refnum) == noErr )
  49.         NumToStr( paramPtr, (long)refnum, &str );
  50.     else
  51.         str.data[0] = '\0';        /* return empty if not opening */
  52.  
  53.     paramPtr->returnValue = PasToZero( paramPtr, &str );
  54. }
  55.  
  56.